package cn.cimoc.controller;

import cn.cimoc.annotation.ResponseResult;
import cn.cimoc.model.dto.inut.CartInput;
import cn.cimoc.model.dto.output.ProductDTO;
import cn.cimoc.model.dto.output.ProductDetails;
import cn.cimoc.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/products")
@ResponseResult
public class ProductController {

    @Autowired
    ProductService service;

    @PreAuthorize("hasAuthority('/product/show')")
    @GetMapping("/hot")
    public List<ProductDTO> hot() {
        return service.getHot();
    }

    @PreAuthorize("hasAuthority('/product/show')")
    @GetMapping("/{id}/details")
    public ProductDetails details(@PathVariable("id")Long id) {
        return service.getDetails(id);
    }


}
